Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Language Guide / Part 3 - Appendixes
Appendix B - Scriptable Text Editor Dictionary / About Text Objects


Text Styles

The text styles of Scriptable Text Editor text objects are defined by two properties: Style and Uniform Styles:

The value of a Style or Uniform Styles property is a record with two properties: On Styles and Off Styles. The On Styles property specifies styles that are "on," that is, that apply to the text object. The Off Styles property specifies styles that are "off," that is, that do not apply to the text object. Both On Styles and Off Styles are lists of constants that specify text styles. For the Scriptable Text Editor, these constants are bold, italic, outline, underline, and shadow.

The following example shows the value of a Style property for a text object whose characters are bold and underlined:

{On Styles:{bold, underline}, Off Styles:{italic, outline, shadow}}
The On Styles property lists the two styles (bold and underline) that apply to the text object, while the Off Styles property lists the styles that do not apply to the text object. Together, the On Styles and Off Styles properties of a Style property include all of the text styles that the Scriptable Text Editor supports.

The Uniform Styles property specifies the styles that are uniform throughout a text object, that is, that are the same for every character in a text object. The On Styles property specifies the styles that apply to every character in the object. The Off Styles property specifies styles that do not apply to any character in the text object. If any of the style constants (bold, italic, outline, underline, and shadow) do not appear in either field, it is because the styles apply to some, but not all, of the characters in the object.

The following example shows the value of a Uniform Styles property for a
text object in which every character is bold and no characters are outlined
or shadowed:

{On Styles:{bold}, Off Styles:{outline, shadow}}
The fact that the italic and underline constants do not appear in either field means that at least one, but not all, of the characters in the object are italicized and underlined. To find out which characters are italicized or underlined, you must examine the Style properties of each character in the
text object.

To set the styles of a text object, use a Copy or Set command to set the Style property of the text object to one of the following:

For example, here are four ways to use the Set command to set text styles:

set the style of word 1 to {On Styles:{italic}, ÿ 
   Off Styles:{bold, shadow}}
set the style of word 1 to {On Styles:{italic, bold}}
set the style of word 1 to {bold, italic}
set the style of word 1 to italic
When you set the style of a text object, if you include the same style constant in both the On Styles property and the Off Styles property, the Scriptable Text Editor returns the error Bad data.

When setting text styles, you can use a special constant--plain--to specify that the text object is to be plain, that is, have no text styles. If you include constants other than plain in the On Styles property, the Scriptable Text Editor ignores the other constants. If you include plain in the Off Styles property, the Scriptable Text Editor returns the error Bad data.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996